﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Besture.Bll;

namespace Besture.UI.Portal.HelpCenter
{
    public partial class QAList : System.Web.UI.Page
    {
        #region 初始化
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //绑定左侧导航
                var dt = QueryDac.GetTable(string.Format(@"
                SELECT * FROM dbo.TBPart
                WHERE ParentID=134 
                ORDER BY SortID ASC "));
                repHelpCenter.DataSource = dt;
                repHelpCenter.DataBind();

                InitData();
            }
        }

        #endregion

        #region 加载数据
        /// <summary>
        /// 加载数据
        /// </summary>
        private void InitData()
        {
            var dt = QueryDac.GetTable(string.Format(@"
            SELECT * FROM dbo.TBPartContent
            WHERE PartID=139 AND IsDisplay=1
            ORDER BY SortID ASC "));
            AspNetPager1.RecordCount = dt.Rows.Count;
            var pds = new PagedDataSource
            {
                AllowPaging = true,
                DataSource = dt.DefaultView,
                PageSize = AspNetPager1.PageSize,
                CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1
            };
            repQaList.DataSource = pds;
            repQaList.DataBind();
        }
        #endregion

        #region 分页事件
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="src"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            InitData();
        }
        #endregion
    }
}